package com.weilai.common.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;

/**
 * Created by Song on 2017/6/22.
 */
@WebServlet("/wxLogin")
public class WxLoginServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String backUrl = "http://123.207.144.58:8080/callBack";
        String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+AuthUtil.APPID
                +"&redirect_uri=" + URLEncoder.encode(backUrl)
                +"&response_type=code"
                +"&scope=snsapi_userinfo"
                +"&state=STATE&connect_redirect=1#wechat_redirect";
        resp.sendRedirect(url);
    }

}
